package com.he.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {
    private Integer code;//业务状态码，1-成功，0-失败
    private String message;//提示信息
    private T data;//响应数据

    //快速返回操作成功响应结果（带响应数据）
    public static <E> Result<E> success(E data){
        Result<E> r = new Result<>();
        r.code = 1;
        r.message = "success!";
        r.data = data;
        return r;
    }

    public static Result success(){
        Result r = new Result<>();
        r.code = 1;
        r.message = "success!";
        r.data = null;
        return r;
    }


    public static Result error(String message){
        Result r = new Result<>();
        r.code = 0;
        r.message = message;
        r.data = null;
        return r;
    }
}
